import request from '../utils/request'

// 登录
export const login = ({ username, password }) => request.post('/user/login', { username, password })

// 注册
export const register = ({ username, password } ) => request.post('/user/register', { username, password })

// 发送验证码
export const sendVerifyCode = (email) => request.post('/user/sendCode', { email })

// 通过邮箱验证码登录
export const loginByEmailCode = ({ email, code }) => request.post('/user/loginByEmailCode', { email, code })

// 通过邮箱验证码注册
export const registerByEmailCode = ({ email, code }) => request.post('/user/registerByEmailCode', { email, code })

// 获取用户信息
export const getUserInfo = () => request.get('/user/getUserInfo')

// 更新用户信息
export const updateUserInfo = (data) => request.post('/user/updateUserInfo', data)

// 更新用户密码
export const updateUserPassword = (data) => request.post('/user/updatePassword', data)

// 更新用户头像
export const updateAvatar = (data) => request.post('/user/updateAvatar', data)

// 获取用户邮箱
export const getEmailByUsername = (username) => request.post('/user/getEmailByUsername', { username } )

// 设置用户密码
export const updateNewPassword = (data) => request.post('/user/updateNewPassword', data)


